package com.echatim.sdk;

public class Main {
    /*
    private static boolean sdkInitFinished = false;
    private static int apiCallId = 1; // api 调用id, 实现方式可用时间戳, 或一个自增变量
    

    static void sdkTestApis() throws InterruptedException {
        // 测试 'userGet'
        while (true){
//            EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "userGet", "{\"auid\":\"admin\"}");

//        //  测试API
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "userUpdate", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "userList", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "userGet", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "userUpdateToken", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "userRefreshToken", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "historyListMessage", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "historyListSession", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "addFriend", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "delFriend", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "listFriends", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "getFriend", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "modifyBlacklistForbid", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "listBlackListForbid", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "modifyAlias", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "addRoom", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "updateRoom", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "listRoom", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "listRoomJoin", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "delRoom", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "getRoom", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "listRoomMember", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "addRoomMember", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "delRoomMember", "{}");
        EChatIMSDKBridge.sdkInvokeApi(apiCallId++, "userOnline", "{}");

            Thread.sleep(10*1000);
        }

    }

    
    public static void main(String[] args) throws InterruptedException {
        String configJson = "{\"host\":\"api.echatim.cn\",\"httpPort\":58082,\"socketPort\":59092,\"key\":\"TSDKTEST00001\",\"secret\":\"\",\"apiTransport\":\"HTTP\",\"loginAuid\":\"admin\",\"loginToken\":\"admin\"}";
        EChatIMSDKBridge.sdkInit(configJson, (ret, errMsg)->{
            if(ret == 0){
                sdkInitFinished = true;
            }
        }, (message, argv) -> {
            if(!"".equals(message) && argv.length > 0){
                System.out.println(String.format("sdk_listener_callback_handler: message = %s, argv[0]=%s", message, argv[0]));
            }
        });

        // 等待sdk初始完成.
        while (!sdkInitFinished){
            Thread.sleep(100);
            System.out.print(".");
        }
        // api 回调处理
        EChatIMSDKBridge.sdkSetApiListener((callId, method, jsonParams) -> {
            if(!"".equals(method) && !"".equals(jsonParams)){
                System.out.println(String.format("api_listener_callback_handler: callId=%d, method = %s, jsonParams=%s", callId, method, jsonParams));
            }
        });

        sdkTestApis();
    }
    */
}
